package net.csdn.business.notify.api.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.csdn.business.notify.common.model.dto.NewNotifyAnnounceDTO;
import net.csdn.business.notify.common.model.dto.UpdateNotifyAnnounceDTO;
import net.csdn.business.notify.common.model.query.NotifyAnnounceQuery;
import net.csdn.business.notify.common.model.vo.NotifyAnnounceVO;
import net.csdn.business.notify.api.service.INotifyAnnounceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;



/**
 * @ClassName NotifyAnnounceController
 * @Description -系统公告Controller
 * @Author zhangyl
 * @Date 2023/12/6 19:18
 */
@RestController
@RequestMapping("/api/v1/notify/announce")
public class NotifyAnnounceController
{
    @Autowired
    private INotifyAnnounceService notifyAnnounceService;

    /**
     * 分页查询通知中心-系统公告列表
     */

    @PostMapping("/list")
    public Page<NotifyAnnounceVO> findPageList(@RequestBody NotifyAnnounceQuery query)
    {
        return notifyAnnounceService.findPageList(query);
    }


    /**
     * 根据id获取通知中心-系统公告详细信息
     */
    @GetMapping(value = "/{id}")
    public NotifyAnnounceVO getInfo(@PathVariable("id") String id)
    {
        return notifyAnnounceService.selectNotifyAnnounceById(id);
    }

    /**
     * 新增通知中心-系统公告
     */
    @PostMapping
    public Integer add(@RequestBody @Validated NewNotifyAnnounceDTO notifyAnnounce)
    {
        return notifyAnnounceService.insertNotifyAnnounce(notifyAnnounce);
    }

    /**
     * 修改通知中心-系统公告
     */
    @PutMapping
    public Integer edit(@RequestBody @Validated UpdateNotifyAnnounceDTO notifyAnnounce)
    {
        return notifyAnnounceService.updateNotifyAnnounce(notifyAnnounce);
    }

    /**
     * 删除通知中心-系统公告
     */
	@DeleteMapping("/{id}")
    public Integer remove(@PathVariable("id") String id)
    {
        return notifyAnnounceService.deleteNotifyAnnounceById(id);
    }
}
